package com.neuedu.corejava.ch10;

import java.util.Deque;
import java.util.LinkedList;

public class LinkedListClass {
	public static void main(String[] args) {
		// LinkedList类实现了多种数据结构
		// 实现了（双端）链接结构，队列

		// 队列结构
		// 队列结构具有先进先出，后进后出
		// LinkedList<Computer> linkedList=new LinkedList<Computer>();
		Deque<Computer> linkedList = new LinkedList<Computer>();
		linkedList.addLast(new Computer("hp1", 4900));
		linkedList.addLast(new Computer("hp2", 4900));
		linkedList.addLast(new Computer("hp3", 4900));
		linkedList.addLast(new Computer("hp4", 4900));
		linkedList.addLast(new Computer("hp5", 4900));
		linkedList.addLast(new Computer("hp6", 4900));
		
		Computer computer = null;
		while ((computer = linkedList.pollFirst()) != null) {
			System.out.println(computer);
		}
		
		System.out.println("=====================");
		// 双端队列
		linkedList.addFirst(new Computer("hp1", 4900));
		linkedList.addFirst(new Computer("hp2", 4900));
		linkedList.addFirst(new Computer("hp3", 4900));
		linkedList.addFirst(new Computer("hp4", 4900));
		linkedList.addFirst(new Computer("hp5", 4900));
		linkedList.addFirst(new Computer("hp6", 4900));
		
		while ((computer = linkedList.pollFirst()) != null) {
			System.out.println(computer);
		}
	}

}
